package cn.lovezsm.bjcjbase.config;

import cn.lovezsm.bjcjbase.bean.AP;
import cn.lovezsm.bjcjbase.data.DataParser;
import lombok.AllArgsConstructor;
import lombok.Data;

import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Data
@Component
@AllArgsConstructor
@NoArgsConstructor
public class APConfig{

    private Set<AP> apList = new HashSet<>();

    public int getAPSize(){
        return apList.size();
    }
    /**
     * @param apMac
     * @return 找到后返回ap的序号，否则返回-1
     */
    public int getAPIndex(String apMac){
        apMac = DataParser.parseMac(apMac);
        for (AP ap:apList){
            if(ap.getMac().equals(apMac)){
                return ap.getIndex();
            }
        }
        return -1;
    }


}
